<?php
class shzSDK{
    private $AppID;
    private $AppKey;

    //设置appid，appkey
    function __construct($AppID,$AppKey){
        $this->AppID = 'APPID:'.$AppID;
        $this->AppKey = 'APPKEY:'.$AppKey;
    }

    function __call($func ,$arr=array()){
        if ($func == 'cates') {
            $url = 'http://gateway.shihuizhu.net/open/cates';
        } else {
            $url = "http://gateway.shihuizhu.net/open/{$func}/{$arr[0]}/{$arr[1]}";
        }
        return $this->get_curl($url);
    }

    function get_curl($url){
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array($this->AppID,$this->AppKey));
        curl_setopt($ch, CURLOPT_TIMEOUT, 20);
        $result = curl_exec($ch);
        curl_close($ch);
        return $result;
    }
}
?>